home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Reading Formatted Text
- Sent: 6/11/96 11:20 PM
- Received: 6/12/96 8:31 AM
- From: Jim Lloyd, jim@melongem.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- At 11:27 AM 6/11/96, Serge Froment wrote:
- >>As you've noticed, ODF R1 doesn't provide anything that exactly meets your
- >>needs. FW_CTextReader is the most appropriate ODF class for this task. The
- >>idea is to create tool classes that use TextReader interfaces. For
- >>example, you might write a lexical analyzer class along these lines:
- >
- >Jim:
- >
- >Thank you for your detailed answer. I ended up doing somewhat what you
- >said, using FW_CTextReader::PeekRunAhead to copy the text inside a
- >FW_CString where I can search for delimiters. Here is the code a came up
- >with:
- >
- > [ code snipped ]
- >
- >However, I am a bit concerned about the efficiency of such a method in the
- >case the clipboard contain a large text. (I was done writing the code late
- >last evening and I have not yet tested what happen in that case.)
-
- Yes, efficiency might be a concern with the code you show. Suppose you
- read in a couple hundred bytes (length==200), and there are no delimiters,
- or \r characters. FW_CString::FindCharacter will have to make two passes
- through the data to determine that. What's worse, after you call
- FW_CTextReader::Advance, FindCharacter will have to pass through those same
- two hundred characters at least one more time. Of course, it is probable
- that the data you're processing is formatted into columns that are rarely
- if ever more than 20 characters, so your code will probably not be a
- noticeable bottleneck.
-
- Your code would be better if FW_CString had a function to fine the first
- occurence of a character from a set of characters, but unfortunately it
- doesn't. There is a wide range of text processing algorithms that it would
- have been nice if ODF provided, but we had to draw the line somewhere, and
- since these things were not directly related to building a framework for
- OpenDoc parts we felt it was better to not try to do too much.
-
- Jim Lloyd
-
-